<%@LANGUAGE="JSCRIPT" CODEPAGE="65001"%>
<!--#include file="lang/blog.asp"-->
<!--#include file="class/functions.asp"-->
<!--#include file="class/dbconn.asp"-->
<%
//====== Upgrade PAGE ========================================
// UPGRADE Version 001 for LBS2
//
// Copyright 2005 SiC. All Rights Reserved.
// Last Update: 2005-03-05 12:18:30
//============================================================
Response.Expires = -1;
Response.AddHeader("Pragma","no-cache");
Response.AddHeader("cache-control","no-cache");
Response.Buffer=true;
Session.Timeout=60;

var blogDB="data/blog.mdb";

var inLBS=true;
var inDebug=true;

var lang=new Array(); // Create the language array
getLanguageArray(lang);

// Initialize Function Wrapper
var func=new lbsFunc();

// Get Request Data (QueryString, Form)
var input=func.getInput();

// Initialize DB Connection
var connBlog=new DBConn(blogDB);
connBlog.open();

switch(String(input["in"])){
  case "settings":
    transSettings();
    break;
  case "cdb":
    cleanDB();
    break;
  case "done":
    done();
    break;
  default:
    var strText="<b>Script Engine Version:</b> "+ScriptEngineMajorVersion()+"." +ScriptEngineMinorVersion()+"." +ScriptEngineBuildVersion()+"<br />";
    strText+='Please backup your database first<br /><br /><a href="?in=settings">Click here to start</a> '
    outputEvent("LBS^2 v2.0.304 to v2.0.310 Database Upgrade",strText)
}

connBlog.close();

showSQL();


// Output Events
function outputEvent(strStep, strEvent,strRedirect){
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LBS^2 v2.0.304 to v2.0.310 Database Upgrade</title>
<link rel="stylesheet" type="text/css" href="styles/default/styles.css" />
</head>
<body>
<div id="content" class="content" style="margin:10px;">
<div id="innerContent">
  <div class="textbox-title"><h4><%=strStep%></h4></div>
  <div class="textbox-content">
    <%=strEvent%>
    <%if(strRedirect){%>
    <meta http-equiv="refresh" content="3; URL=<%=strRedirect%>" /><br /><br />
    <a href="<%=strRedirect%>">Click Here If This Page Has Not Redirected Automatically</a>
    <%}%>
 </div>
</div>
</div>
<br />
</body>
</html>
<%
}

// Simplified Response.Write Output
function write(str)
{
  Response.Write(str);
}

// SQL Debug Output
function showSQL()
{
  write("<div style='margin: 10px;width: 100%'><div><table style='background: #CCCCCC; font-size: 12px;' width='100%' cellpadding='3' cellspacing='1'>");
  write("<tr><th>SQL: "+connBlog.queryCount+" queries</th><th>Return</th><th>Total</th></tr>");
  for(var i=0;i<connBlog.debugData.length;i++){
    write("<tr style='background:#FCFCFC'><td>"+Server.HTMLEncode(connBlog.debugData[i][0])+"</td><td>"+connBlog.debugData[i][1]+"</td><td>"+connBlog.debugData[i][2]+"</td></tr>")
  }
  write("</table></div></div>");
}

// Fatal Error Output
function errorMessage(err)
{
  write("<div style='color:#990000; border: solid 1px #CC0000; background: #FFEEDD; margin: 1px; font-size: 12px;'>");
  if(err.constructor==Error){
    write("<div style='color:#FFFFFF; padding: 2px; background: #990000;'>Error Code " + String(err.number & 0xFFFF) + "</div><div style='padding: 2px;'>"+err.description);
  }else{
    write("<div style='padding: 2px;'>"+err);
  }
  write("</div></div>");
  showSQL();
  Response.End();
}

// Done /////////////////////////////////////////////////////////////////
function done(){
  Application.Contents.RemoveAll();
  outputEvent("Transfer Done", "Database is updated. You can use LBS2 Now.<br />(Better Compact the Database File before launch your site)");
}


// Transfer Settings ////////////////////////////////////////////////////////
function transSettings(){
  var strTable="blog_Settings";
  connBlog.insert(strTable,{"set_name": "maxCommentURLCount", "set_type": 0, "set_value0": 2});

  outputEvent("Add Settings", "Settings added", "?in=done");
}
%>
